<template>

  <div
    class="viewport"
    style="background-color: #101129;"
  >

    <div class="column">
      <el-button class="left" style="background-color:#000d4a;height:1.5rem;width:5rem;top:15px;color:white;text-align:center;" @click="toRouter()">后台管理</el-button>
      <div class="overview panel">
        <div class="inner">
          <div class="item">
            <h4>2,190</h4>
            <span>
              <i class="icon-dot" style="color: #006cff" />
              设备总数
            </span>
          </div>
          <div class="item">
            <h4>190</h4>
            <span>
              <i class="icon-dot" style="color: #6acca3" />
              季度新增
            </span>
          </div>
          <div class="item">
            <h4>3,001</h4>
            <span>
              <i class="icon-dot" style="color: #6acca3" />
              运营设备
            </span>
          </div>
          <div class="item">
            <h4>108</h4>
            <span>
              <i class="icon-dot" style="color: #ed3f35" />
              异常设备
            </span>
          </div>
        </div>
      </div>
      <!--监控-->
      <div class="monitor panel">
        <div class="inner">
          <div class="tabs">
            <a href="javascript:;" data-index="0" class="active">故障设备监控</a>
            <a href="javascript:;" data-index="1">异常设备监控</a>
          </div>
          <div class="content" style="display: block;">
            <div class="head">
              <span class="col">故障时间</span>
              <span class="col">设备地址</span>
              <span class="col">异常代码</span>
            </div>
            <div class="marquee-view">
              <div class="marquee">
                <div class="row">
                  <span class="col">20180701</span>
                  <span class="col">11北京市昌平西路金燕龙写字楼</span>
                  <span class="col">1000001</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190601</span>
                  <span class="col">北京市昌平区城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190704</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000003</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20180701</span>
                  <span class="col">北京市昌平区建路金燕龙写字楼</span>
                  <span class="col">1000004</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190701</span>
                  <span class="col">更多模板关注公众号【DreamCoders】</span>
                  <span class="col">1000005</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190701</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000006</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190701</span>
                  <span class="col">北京市昌平区建西路金燕龙写字楼</span>
                  <span class="col">1000007</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190701</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000008</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190701</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000009</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190710</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000010</span>
                  <span class="icon-dot" />
                </div>
              </div>
            </div>
          </div>
          <div class="content">
            <div class="head">
              <span class="col">异常时间</span>
              <span class="col">设备地址</span>
              <span class="col">异常代码</span>
            </div>
            <div class="marquee-view">
              <div class="marquee">
                <div class="row">
                  <span class="col">20190701</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000001</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190701</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190703</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190704</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190705</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190706</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190707</span>
                  <span class="col">更多模板关注公众号【DreamCoders】</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190708</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190709</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
                <div class="row">
                  <span class="col">20190710</span>
                  <span class="col">北京市昌平区建材城西路金燕龙写字楼</span>
                  <span class="col">1000002</span>
                  <span class="icon-dot" />
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!--点位-->
      <div class="point panel">
        <div class="inner">
          <h3>点位分布统计</h3>
          <div class="chart">
            <div class="pie" />
            <div class="data">
              <div class="item">
                <h4>320,11</h4>
                <span>
                  <i class="icon-dot" style="color: #ed3f35" />
                  点位总数
                </span>
              </div>
              <div class="item">
                <h4>418</h4>
                <span>
                  <i class="icon-dot" style="color: #eacf19" />
                  本月新增
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="column">
      <!-- 地图 -->
      <div class="map">
        <h3>
          <span class="icon-cube" />
          设备数据统计
        </h3>
        <div class="chart">
          <div class="geo" />
        </div>
      </div>
      <!-- 用户 -->
      <div class="users panel">
        <div class="inner">
          <h3>全国用户总量统计</h3>
          <div class="chart">
            <div class="bar" />
            <div class="data">
              <div class="item">
                <h4>120,899</h4>
                <span>
                  <i class="icon-dot" style="color: #ed3f35" />
                  用户总量
                </span>
              </div>
              <div class="item">
                <h4>248</h4>
                <span>
                  <i class="icon-dot" style="color: #eacf19" />
                  本月新增
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="column">
      <div class="order panel">
        <div class="inner">
          <!-- 筛选 -->
          <div class="filter">
            <a href="javascript:;" data-key="day365" class="active">365天</a>
            <a href="javascript:;" data-key="day90">90天</a>
            <a href="javascript:;" data-key="day30">30天</a>
            <a href="javascript:;" data-key="day1">24小时</a>
          </div>
          <!-- 数据 -->
          <div class="data">
            <div class="item">
              <h4>20,301,987</h4>
              <span>
                <i class="icon-dot" style="color: #ed3f35;" />
                订单量
              </span>
            </div>
            <div class="item">
              <h4>99834</h4>
              <span>
                <i class="icon-dot" style="color: #eacf19;" />
                销售额(万元)
              </span>
            </div>
          </div>
        </div>
      </div>
      <!-- 销售额 -->
      <div class="sales panel">
        <div class="inner">
          <div class="caption">
            <h3>销售额统计</h3>
            <a href="javascript:;" class="active" data-type="year">年</a>
            <a href="javascript:;" data-type="quarter">季</a>
            <a href="javascript:;" data-type="month">月</a>
            <a href="javascript:;" data-type="week">周</a>
          </div>
          <div class="chart">
            <div class="label">单位:万</div>
            <div class="line" />
          </div>
        </div>
      </div>
      <!-- 渠道 季度 -->
      <div class="wrap">
        <div class="channel panel">
          <div class="inner">
            <h3>渠道分布</h3>
            <div class="data">
              <div class="item">
                <h4>39 <small>%</small></h4>
                <span>
                  <i class="icon-plane" />
                  机场
                </span>
              </div>
              <div class="item">
                <h4>28 <small>%</small></h4>
                <span>
                  <i class="icon-bag" />
                  商场
                </span>
              </div>
            </div>
            <div class="data">
              <div class="item">
                <h4>20 <small>%</small></h4>
                <span>
                  <i class="icon-train" />
                  地铁
                </span>
              </div>
              <div class="item">
                <h4>13 <small>%</small></h4>
                <span>
                  <i class="icon-bus" />
                  火车站
                </span>
              </div>
            </div>
          </div>
        </div>
        <div class="quarter panel">
          <div class="inner">
            <h3>一季度销售进度</h3>
            <div class="chart">
              <div class="box">
                <div class="gauge" />
                <div class="label">75<small> %</small></div>
              </div>
              <div class="data">
                <div class="item">
                  <h4>1,321</h4>
                  <span>
                    <i class="icon-dot" style="color: #6acca3" />
                    销售额(万元)
                  </span>
                </div>
                <div class="item">
                  <h4>150%</h4>
                  <span>
                    <i class="icon-dot" style="color: #ed3f35" />
                    同比增长
                  </span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <!-- 排行榜 -->
      <div class="top panel">
        <div class="inner">
          <div class="all">
            <h3>全国热榜</h3>
            <ul>
              <li>
                <i class="icon-cup1" style="color: #d93f36;" />
                可爱多
              </li>
              <li>
                <i class="icon-cup2" style="color: #68d8fe;" />
                娃哈啥
              </li>
              <li>
                <i class="icon-cup3" style="color: #4c9bfd;" />
                喜之郎
              </li>
            </ul>
          </div>
          <div class="province">
            <h3>各省热销 <i class="date">// 近30日 //</i></h3>
            <div class="data">
              <ul class="sup">
                <li>
                  <span>北京</span>
                  <span>25,179 <s class="icon-up" /></span>
                </li>
                <li>
                  <span>河北</span>
                  <span>23,252 <s class="icon-down" /></span>
                </li>
                <li>
                  <span>上海</span>
                  <span>20,760 <s class="icon-up" /></span>
                </li>
                <li>
                  <span>江苏</span>
                  <span>23,252 <s class="icon-down" /></span>
                </li>
                <li>
                  <span>山东</span>
                  <span>20,760 <s class="icon-up" /></span>
                </li>
              </ul>
              <ul class="sub">
                <!-- <li><span>数据</span><span> 数据<s class="icon-up"></s></span></li> -->
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

</template>

<script>
import 'echarts/map/js/china'
import echarts from 'echarts'
import $ from 'jquery'

var geoCoordMap = {
  '新疆玛纳斯基地': [86.22, 44.30],
  '九江': [116.00, 29.70],
  '新乡': [116.402217, 35.311657],
  ' ': [79.92, 37.12],
  '  ': [86.85, 47.70],
  '若羌县': [88.17, 39.02],
  '上海': [121.4648, 31.2891],
  '东莞': [113.8953, 22.901],
  '东营': [118.7073, 37.5513],
  '中山': [113.4229, 22.478],
  '临汾': [111.4783, 36.1615],
  '临沂': [118.3118, 35.2936],
  '丹东': [124.541, 40.4242],
  '丽水': [119.5642, 28.1854],
  '乌鲁木齐': [87.9236, 43.5883],
  '佛山': [112.8955, 23.1097],
  '保定': [115.0488, 39.0948],
  '兰州': [103.5901, 36.3043],
  '包头': [110.3467, 41.4899],
  '北京': [116.4551, 40.2539],
  '北海': [109.314, 21.6211],
  '南京': [118.8062, 31.9208],
  '南宁': [108.479, 23.1152],
  '南昌': [116.0046, 28.6633],
  '南通': [121.1023, 32.1625],
  '厦门': [118.1689, 24.6478],
  '台州': [121.1353, 28.6688],
  '合肥': [117.29, 32.0581],
  '呼和浩特': [111.4124, 40.4901],
  '咸阳': [108.4131, 34.8706],
  '哈尔滨': [127.9688, 45.368],
  '唐山': [118.4766, 39.6826],
  '嘉兴': [120.9155, 30.6354],
  '大同': [113.7854, 39.8035],
  '大连': [122.2229, 39.4409],
  '天津': [117.4219, 39.4189],
  '太原': [112.3352, 37.9413],
  '威海': [121.9482, 37.1393],
  '宁波': [121.5967, 29.6466],
  '宝鸡': [107.1826, 34.3433],
  '宿迁': [118.5535, 33.7775],
  '常州': [119.4543, 31.5582],
  '广州': [113.5107, 23.2196],
  '廊坊': [116.521, 39.0509],
  '延安': [109.1052, 36.4252],
  '张家口': [115.1477, 40.8527],
  '徐州': [117.5208, 34.3268],
  '德州': [116.6858, 37.2107],
  '惠州': [114.6204, 23.1647],
  '成都': [103.9526, 30.7617],
  '扬州': [119.4653, 32.8162],
  '承德': [117.5757, 41.4075],
  '拉萨': [91.1865, 30.1465],
  '无锡': [120.3442, 31.5527],
  '日照': [119.2786, 35.5023],
  '昆明': [102.9199, 25.4663],
  '杭州': [119.5313, 29.8773],
  '枣庄': [117.323, 34.8926],
  '柳州': [109.3799, 24.9774],
  '株洲': [113.5327, 27.0319],
  '武汉': [114.3896, 30.6628],
  '汕头': [117.1692, 23.3405],
  '江门': [112.6318, 22.1484],
  '沈阳': [123.1238, 42.1216],
  '沧州': [116.8286, 38.2104],
  '河源': [114.917, 23.9722],
  '泉州': [118.3228, 25.1147],
  '泰安': [117.0264, 36.0516],
  '泰州': [120.0586, 32.5525],
  '济南': [117.1582, 36.8701],
  '济宁': [116.8286, 35.3375],
  '海口': [110.3893, 19.8516],
  '淄博': [118.0371, 36.6064],
  '淮安': [118.927, 33.4039],
  '深圳': [114.5435, 22.5439],
  '清远': [112.9175, 24.3292],
  '温州': [120.498, 27.8119],
  '渭南': [109.7864, 35.0299],
  '湖州': [119.8608, 30.7782],
  '湘潭': [112.5439, 27.7075],
  '滨州': [117.8174, 37.4963],
  '潍坊': [119.0918, 36.524],
  '烟台': [120.7397, 37.5128],
  '玉溪': [101.9312, 23.8898],
  '珠海': [113.7305, 22.1155],
  '盐城': [120.2234, 33.5577],
  '盘锦': [121.9482, 41.0449],
  '石家庄': [114.4995, 38.1006],
  '福州': [119.4543, 25.9222],
  '秦皇岛': [119.2126, 40.0232],
  '绍兴': [120.564, 29.7565],
  '聊城': [115.9167, 36.4032],
  '肇庆': [112.1265, 23.5822],
  '舟山': [122.2559, 30.2234],
  '苏州': [120.6519, 31.3989],
  '莱芜': [117.6526, 36.2714],
  '菏泽': [115.6201, 35.2057],
  '营口': [122.4316, 40.4297],
  '葫芦岛': [120.1575, 40.578],
  '衡水': [115.8838, 37.7161],
  '衢州': [118.6853, 28.8666],
  '西宁': [101.4038, 36.8207],
  '西安': [109.1162, 34.2004],
  '贵阳': [106.6992, 26.7682],
  '连云港': [119.1248, 34.552],
  '邢台': [114.8071, 37.2821],
  '邯郸': [114.4775, 36.535],
  '郑州': [113.4668, 34.6234],
  '鄂尔多斯': [108.9734, 39.2487],
  '重庆': [107.7539, 30.1904],
  '金华': [120.0037, 29.1028],
  '铜川': [109.0393, 35.1947],
  '银川': [106.3586, 38.1775],
  '镇江': [119.4763, 31.9702],
  '长春': [125.8154, 44.2584],
  '长沙': [113.0823, 28.2568],
  '长治': [112.8625, 36.4746],
  '阳泉': [113.4778, 38.0951],
  '青岛': [120.4651, 36.3373],
  '韶关': [113.7964, 24.7028]
}
var BJData = [
  [{
    name: '新乡'
  }, {
    name: '新乡',
    value: 200
  }],
  [{
    name: '新乡'
  }, {
    name: '呼和浩特',
    value: 90
  }],
  [{
    name: '新乡'
  }, {
    name: '哈尔滨',
    value: 90
  }],
  [{
    name: '新乡'
  }, {
    name: '石家庄',
    value: 90
  }],
  [{
    name: '新乡'
  }, {
    name: '昆明',
    value: 30
  }],
  [{
    name: '新乡'
  }, {
    name: '北京',
    value: 100
  }],
  [{
    name: '新乡'
  }, {
    name: '长春',
    value: 40
  }],
  [{
    name: '新乡'
  }, {
    name: '重庆',
    value: 40
  }],
  [{
    name: '新乡'
  }, {
    name: '贵阳',
    value: 50
  }],
  [{
    name: '新乡'
  }, {
    name: '南宁',
    value: 30
  }],
  [{
    name: '新乡'
  }, {
    name: '济南',
    value: 10
  }],
  [{
    name: '新乡'
  }, {
    name: '太原',
    value: 40
  }],
  [{
    name: '新乡'
  }, {
    name: '西安',
    value: 60
  }],
  [{
    name: '新乡'
  }, {
    name: '武汉',
    value: 50
  }],
  [{
    name: '新乡'
  }, {
    name: '合肥',
    value: 40
  }],
  [{
    name: '新乡'
  }, {
    name: '南京',
    value: 30
  }],
  [{
    name: '新乡'
  }, {
    name: '沈阳',
    value: 20
  }],
  [{
    name: '新乡'
  }, {
    name: '成都',
    value: 10
  }]
]
var SHData = [
  [{
    name: '九江'
  }, {
    name: '九江',
    value: 200
  }],

  [{
    name: '九江'
  }, {
    name: '长沙',
    value: 95
  }],
  [{
    name: '九江'
  }, {
    name: '武汉',
    value: 30
  }],
  [{
    name: '九江'
  }, {
    name: '南昌',
    value: 20
  }],
  [{
    name: '九江'
  }, {
    name: '合肥',
    value: 70
  }],
  [{
    name: '九江'
  }, {
    name: '南京',
    value: 60
  }],
  [{
    name: '九江'
  }, {
    name: '福州',
    value: 50
  }],
  [{
    name: '九江'
  }, {
    name: '上海',
    value: 100
  }],
  [{
    name: '九江'
  }, {
    name: '深圳',
    value: 100
  }]

]
var GZData = [
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: '新疆玛纳斯基地',
    value: 200
  }],
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: '  ',
    value: 90
  }],
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: ' ',
    value: 40
  }],
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: '呼和浩特',
    value: 90
  }],
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: '昆明',
    value: 40
  }],
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: '成都',
    value: 10
  }],
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: '兰州',
    value: 95
  }],
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: '银川',
    value: 90
  }],
  [{
    name: '新疆玛纳斯基地'
  }, {
    name: '西宁',
    value: 80
  }]

]

var planePath = 'path://M.6,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705'

var color = ['#3ed4ff', '#ffa022', '#a6c84c']
var series = []
export default {
  data() {
    return {
      t: null,
      cityData: [
        ['新乡', BJData],
        ['九江', SHData],
        ['新疆', GZData]]
    }
  },
  computed() {

  },
  mounted() {
    this.getFont()
    this.getMapChart()
    this.getUseChart()
    this.userChart()

    this.getSaleChart()
    this.getOrderChart()
    this.getUpPic()
    this.getOther()
    this.getWeiTuo()
  },
  methods: {
    toRouter() {
      this.$router.push('/dashboard')
    },
    convertData(data) {
      var res = []
      for (var i = 0; i < data.length; i++) {
        var dataItem = data[i]
        var fromCoord = geoCoordMap[dataItem[0].name]
        var toCoord = geoCoordMap[dataItem[1].name]
        if (fromCoord && toCoord) {
          res.push([{
            coord: fromCoord
          }, {
            coord: toCoord
          }])
        }
      }
      return res
    },
    getMapChart() {
      var myecharts = echarts.init($('.map .geo')[0])
      var other = this

      this.cityData.forEach(function(item, i) {
        var that = other
        series.push({
          name: item[0] + ' Top10',
          type: 'lines',
          zlevel: 1,
          effect: {
            show: true,
            period: 6,
            trailLength: 0.7,
            color: '#fff',
            symbolSize: 3
          },
          lineStyle: {
            normal: {
              color: color[i],
              width: 0,
              curveness: 0.2
            }
          },
          data: that.convertData(item[1])
        }, {
          name: item[0] + ' Top10',
          type: 'lines',
          zlevel: 2,
          effect: {
            show: true,
            period: 6,
            trailLength: 0,
            symbol: planePath,
            symbolSize: 15
          },
          lineStyle: {
            normal: {
              color: color[i],
              width: 1,
              opacity: 0.4,
              curveness: 0.2
            }
          },
          data: that.convertData(item[1])
        }, {
          name: item[0] + ' Top10',
          type: 'effectScatter',
          coordinateSystem: 'geo',
          zlevel: 2,
          rippleEffect: {
            brushType: 'stroke'
          },
          label: {
            normal: {
              show: true,
              position: 'right',
              formatter: '{b}'
            }
          },
          symbolSize: function(val) {
            return val[2] / 8
          },
          itemStyle: {
            normal: {
              color: color[i]
            }
          },
          data: item[1].map(function(dataItem) {
            return {
              name: dataItem[1].name,
              value: geoCoordMap[dataItem[1].name].concat([dataItem[1].value])
            }
          })
        })
      })
      var option = {
        backgroundColor: '#080a20',
        title: {
          left: 'left',
          textStyle: {
            color: '#fff'
          }
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          top: 'bottom',
          left: 'right',
          data: ['北京 Top10', '上海 Top10', '广州 Top10'],
          textStyle: {
            color: '#fff'
          },
          selectedMode: 'single'
        },
        geo: {
          map: 'china',
          zoom: 1.2,
          label: {
            emphasis: {
              show: false
            }
          },
          roam: true,
          itemStyle: {
            normal: {
              areaColor: '#142957',
              borderColor: '#0692a4'
            },
            // 选中后的颜色
            emphasis: {
              areaColor: '#0b1c2d'
            }
          }
        },
        series: series
      }
      myecharts.setOption(option)
    },
    // 点位分布图
    getUseChart() {
      var myechart = echarts.init($('.pie')[0])
      var option = {
        // 控制提示
        tooltip: {
          // 非轴图形，使用item的意思是放到数据对应图形上触发提示
          trigger: 'item',
          // 格式化提示内容：
          // a 代表图表名称 b 代表数据名称 c 代表数据  d代表  当前数据/总数据的比例
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        // 控制图表
        series: [
          {
            // 图表名称
            name: '地区',
            // 图表类型
            type: 'pie',
            // 南丁格尔玫瑰图 有两个圆  内圆半径10%  外圆半径70%
            // 百分比基于  图表DOM容器的半径
            radius: ['10%', '70%'],
            // 图表中心位置 left 50%  top 50% 距离图表DOM容器
            center: ['50%', '50%'],
            // 半径模式，另外一种是 area 面积模式
            roseType: 'radius',
            // 数据集 value 数据的值 name 数据的名称
            data: [
              { value: 20, name: '云南' },
              { value: 5, name: '北京' },
              { value: 15, name: '山东' },
              { value: 25, name: '河北' },
              { value: 20, name: '江苏' },
              { value: 35, name: '浙江' },
              { value: 30, name: '四川' },
              { value: 40, name: '湖北' }
            ],
            // 文字调整
            label: {
              fontSize: 10
            },
            // 引导线
            labelLine: {
              length: 8,
              length2: 10
            }
          }
        ],
        color: ['#006cff', '#60cda0', '#ed8884', '#ff9f7f', '#0096ff', '#9fe6b8', '#32c5e9', '#1d9dff']
      }
      myechart.setOption(option)
      myechart.on('click', function(param) {
        alert("更多模板，关注公众号【DreamCoders】\n回复'BigDataView'即可获取\n或前往Gitee下载 https://gitee.com/iGaoWei/big-data-view")
        setTimeout(function() {
          location.href = 'https://gitee.com/iGaoWei/big-data-view'
        }, 20000)
      })
    },
    // 用户总量统计
    userChart() {
      // 中间省略的数据  准备三项
      var item = {
        name: '',
        value: 1200,
        // 柱子颜色
        itemStyle: {
          color: '#254065'
        },
        // 鼠标经过柱子颜色
        emphasis: {
          itemStyle: {
            color: '#254065'
          }
        },
        // 工具提示隐藏
        tooltip: {
          extraCssText: 'opacity:0'
        }
      }
      var option = {
        // 工具提示
        tooltip: {
          // 触发类型  经过轴触发axis  经过轴触发item
          trigger: 'item',
          // 轴触发提示才有效
          axisPointer: {
            // 默认为直线，可选为：'line' 线效果 | 'shadow' 阴影效果
            type: 'shadow'
          }
        },
        // 图表边界控制
        grid: {
          // 距离 上右下左 的距离
          left: '0',
          right: '3%',
          bottom: '3%',
          top: '5%',
          // 大小是否包含文本【类似于boxsizing】
          containLabel: true,
          // 显示边框
          show: true,
          // 边框颜色
          borderColor: 'rgba(0, 240, 255, 0.3)'
        },
        // 控制x轴
        xAxis: [
          {
            // 使用类目，必须有data属性
            type: 'category',
            // 使用 data 中的数据设为刻度文字
            data: ['上海', '广州', '北京', '深圳', '合肥', '', '......', '', '杭州', '厦门', '济南', '成都', '重庆'],
            // 刻度设置
            axisTick: {
              // true意思：图形在刻度中间
              // false意思：图形在刻度之间
              alignWithLabel: false,
              show: false
            },
            // 文字
            axisLabel: {
              color: '#4c9bfd'
            }
          }
        ],
        // 控制y轴
        yAxis: [
          {
            // 使用数据的值设为刻度文字
            type: 'value',
            axisTick: {
              // true意思：图形在刻度中间
              // false意思：图形在刻度之间
              alignWithLabel: false,
              show: false
            },
            // 文字
            axisLabel: {
              color: '#4c9bfd'
            },
            splitLine: {
              lineStyle: {
                color: 'rgba(0, 240, 255, 0.3)'
              }
            }
          }
        ],
        // 控制x轴
        series: [

          {
            // series配置
            // 颜色
            itemStyle: {
              // 提供的工具函数生成渐变颜色
              color: new echarts.graphic.LinearGradient(
                // (x1,y2) 点到点 (x2,y2) 之间进行渐变
                0, 0, 0, 1,
                [
                  { offset: 0, color: '#00fffb' }, // 0 起始颜色
                  { offset: 1, color: '#0061ce' } // 1 结束颜色
                ]
              )
            },
            // 图表数据名称
            name: '用户统计',
            // 图表类型
            type: 'bar',
            // 柱子宽度
            barWidth: '60%',
            // 数据
            data: [2100, 1900, 1700, 1560, 1400, item, item, item, 900, 750, 600, 480, 240]
          }
        ]
      }
      var myechart = echarts.init($('.users .bar')[0])
      myechart.setOption(option)
      myechart.on('click', function(param) {
        alert("更多模板，关注公众号【DreamCoders】\n回复'BigDataView'即可获取\n或前往Gitee下载 https://gitee.com/iGaoWei/big-data-view")
        setTimeout(function() {
          location.href = 'https://gitee.com/iGaoWei/big-data-view'
        }, 20000)
      })
    },
    // 销售额统计
    getSaleChart() {
      var option = {
        // 鼠标提示工具
        tooltip: {
          trigger: 'axis'
        },
        xAxis: {
          // 类目类型
          type: 'category',
          // x轴刻度文字
          data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
          axisTick: {
            show: false// 去除刻度线
          },
          axisLabel: {
            color: '#4c9bfd'// 文本颜色
          },
          axisLine: {
            show: false// 去除轴线
          },
          boundaryGap: false// 去除轴内间距
        },
        yAxis: {
          // 数据作为刻度文字
          type: 'value',
          axisTick: {
            show: false// 去除刻度线
          },
          axisLabel: {
            color: '#4c9bfd'// 文本颜色
          },
          axisLine: {
            show: false// 去除轴线
          },
          boundaryGap: false// 去除轴内间距
        },
        // 图例组件
        legend: {
          textStyle: {
            color: '#4c9bfd' // 图例文字颜色

          },
          right: '10%'// 距离右边10%
        },
        // 设置网格样式
        grid: {
          show: true, // 显示边框
          top: '20%',
          left: '3%',
          right: '4%',
          bottom: '3%',
          borderColor: '#012f4a', // 边框颜色
          containLabel: true // 包含刻度文字在内
        },
        series: [{
          name: '预期销售额',
          // 数据
          data: [24, 40, 101, 134, 90, 230, 210, 230, 120, 230, 210, 120],
          // 图表类型
          type: 'line',
          // 圆滑连接
          smooth: true,
          itemStyle: {
            color: '#00f2f1' // 线颜色
          }
        },
        {
          name: '实际销售额',
          // 数据
          data: [40, 64, 191, 324, 290, 330, 310, 213, 180, 200, 180, 79],
          // 图表类型
          type: 'line',
          // 圆滑连接
          smooth: true,
          itemStyle: {
            color: '#ed3f35' // 线颜色
          }
        }]
      }
      var myechart = echarts.init($('.line')[0])
      myechart.setOption(option)

      // 点击效果
      var data = {
        year: [
          [24, 40, 101, 134, 90, 230, 210, 230, 120, 230, 210, 120],
          [40, 64, 191, 324, 290, 330, 310, 213, 180, 200, 180, 79]
        ],
        quarter: [
          [23, 75, 12, 97, 21, 67, 98, 21, 43, 64, 76, 38],
          [43, 31, 65, 23, 78, 21, 82, 64, 43, 60, 19, 34]
        ],
        month: [
          [34, 87, 32, 76, 98, 12, 32, 87, 39, 36, 29, 36],
          [56, 43, 98, 21, 56, 87, 43, 12, 43, 54, 12, 98]
        ],
        week: [
          [43, 73, 62, 54, 91, 54, 84, 43, 86, 43, 54, 53],
          [32, 54, 34, 87, 32, 45, 62, 68, 93, 54, 54, 24]
        ]
      }
      $('.sales ').on('click', '.caption a', function() {
        $(this).addClass('active').siblings('a').removeClass('active')
        // option series   data
        // 获取自定义属性值
        var key = $(this).attr('data-type')
        // 取出对应的值
        key = data[key]
        // 将值设置到 图表中
        option.series[0].data = key[0]
        option.series[1].data = key[1]
        // 再次调用才能在页面显示
        myechart.setOption(option)
      })
      // 定时器
      var index = 0
      setInterval(function() {
        index++
        if (index > 4) {
          index = 0
        }
        $('.sales .caption a').eq(index).click()
      }, 2000)
    },
    // 订单量
    getOrderChart() {
      var data = {
        day365: { orders: '20,301,987', amount: '99834' },
        day90: { orders: '301,987', amount: '9834' },
        day30: { orders: '1,987', amount: '3834' },
        day1: { orders: '987', amount: '834' }
      }
      // 点击事件
      $('.order').on('click', '.filter a', function() {
        // 点击之后加类名
        $(this).addClass('active').siblings().removeClass('active')
        // 先获取点击a的 data-key自定义属性
        var key = $(this).attr('data-key')
        // 获取自定义属性
        // data{}==>data.shuxing data['shuxing]
        key = data[key]//
        $('.order .item h4:eq(0)').text(key.orders)
        $('.order .item h4:eq(1)').text(key.amount)
      })
      // 定时器
      var index = 0
      var aclick = $('.order a')
      setInterval(function() {
        index++
        if (index > 3) {
          index = 0
        }
        // 每san秒调用点击事件
        aclick.eq(index).click()
      }, 3000)
    },
    getUpPic() {
      var option = {
        series: [
          {
            type: 'pie',
            radius: ['130%', '150%'], // 放大图形
            center: ['50%', '80%'], // 往下移动  套住75%文字
            label: {
              show: false
            },
            startAngle: 180,
            hoverOffset: 0, // 鼠标经过不变大
            data: [
              {
                value: 100,
                itemStyle: { // 颜色渐变#00c9e0->#005fc1
                  color: {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [
                      { offset: 0, color: '#00c9e0' },
                      { offset: 1, color: '#005fc1' }
                    ]
                  }
                }
              },
              { value: 100, itemStyle: { color: '#12274d' }}, // 颜色#12274d

              { value: 200, itemStyle: { color: 'transparent' }}// 透明隐藏第三块区域
            ]
          }
        ]
      }
      var myechart = echarts.init($('.gauge')[0])
      myechart.setOption(option)
    },
    getOther() {
      var data = [
        { name: '可爱多', num: '9,086' },
        { name: '娃哈哈', num: '8,341' },
        { name: '喜之郎', num: '7,407' },
        { name: '八喜', num: '6,080' },
        { name: '小洋人', num: '6,724' },
        { name: '好多鱼', num: '2,170' }
      ]
      $('.inner').on('mouseenter', '.sup li', function() {
        $(this).addClass('active').siblings().removeClass('active')
        // 获取随机的值  sort方法 是给数组排序 a-b是从小到大
        // .5-随机0-1的数 可能为正可能为负 排序就会随机
        var radomData = data.sort(function(a, b) { return 0.5 - Math.random() })
        var html = ''
        radomData.forEach(function(item) {
          html += `<li><span>${item.name}</span><span>${item.num} <s class="icon-up"></s></span></li>`
        })
        // 渲染
        $('.sub').html(html)
      })
      $('.province .sup li').eq(0).mouseenter()
      var index = 0
      setInterval(() => {
        index++
        if (index > 5) {
          index = 0
        }
        $('.sup li').eq(index).mouseenter()
      }, 2000)
    },
    getFont() {
      // 因为要定义变量可能和别的变量相互冲突，污染，所有用自调用函数
      var html = document.documentElement// 获取html
      // 获取宽度
      var width = html.clientWidth

      // 判断
      if (width < 1024) width = 1024
      if (width > 1920) width = 1920
      // 设置html的基准值
      var fontSize = width / 80 + 'px'
      // 设置给html
      html.style.fontSize = fontSize
    },
    getWeiTuo() {
      $('.monitor').on('click', ' a', function() {
        // 点击当前的a 加类名 active  他的兄弟删除类名
        $(this).addClass('active').siblings().removeClass('active')
        // 获取一一对应的下标
        var index = $(this).index()
        // 选取content 然后狗日对应下标的 显示   当前的兄弟.content隐藏
        $('.content').eq(index).show().siblings('.content').hide()
      })
      // 滚动
      // 原理：把marquee下面的子盒子都复制一遍 加入到marquee中
      //      然后动画向上滚动，滚动到一半重新开始滚动
      // 因为选取的是两个marquee  所以要遍历
      $('.monitor .marquee').each(function(index, dom) {
        // 将每个 的所有子级都复制一遍
        var rows = $(dom).children().clone()
        // 再将新的到的加入原来的
        $(dom).append(rows)
      })
    }
  }

}
</script>

